<!DOCTYPE html>
<html lang="en" xmlns:v-bind="http://www.w3.org/1999/xhtml" xmlns:v-model="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>vue网络通信</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2.6.11"></script>
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>

</head>
<body>
<div id="app">
<h1>{{title}}</h1>
    <div>{{content}}</div>
</div>
</body>
<script>
    //组件无法直接获取items,所以定义一个自定义的list属性，将list属性和for循环出来的item进行绑定，通过props将自定义的list属性传递给组件

    // 实例化vue对象
    new Vue({
        el:"#app",
        data:{
            title:"",
            content:""
        },
        mounted(){//钩子函数
            axios.get("data.json").then((response) => {
                var data=response.data.data
                this.title=data.news.title;
                this.content=data.news.content;
            })
        }
    });
</script>
</html>